var t = getApp();

Page({
    data: {
        activity_id: "",
        backgroundRGB: {
            red: 0,
            green: 0,
            black: 0
        },
        userInfo: {
            buy_count: 0,
            commission_sum: 0
        },
        shareOptions: {},
        rankList: [],
        isMore: !1,
        isShow: !1,
        posterImg: ""
    },
    onLoad: function(t) {
        t.id && this.setData({
            activity_id: 1 * t.id
        });
    },
    onShow: function() {
        this.getData();
    },
    onReady: function() {},
    getData: function() {
        var a = this, i = t.getNetAddresss("plugin.deposit-ladder.frontend.index.rankList");
        t._getNetWork({
            url: i,
            data: {
                id: this.data.activity_id
            },
            success: function(i) {
                if (1 == i.data.result) {
                    var s = i.data, e = a.hexStringToRGB(s.data.theme_color);
                    a.setData({
                        userInfo: s.data.member,
                        countList: s.data.rankList,
                        commission: s.data.commission,
                        shareOptions: s.data.share,
                        backgroundRGB: e
                    }), s.data.rankList.length >= 10 ? a.setData({
                        rankList: a.data.countList.slice(0, 10),
                        isMore: !0
                    }) : a.setData({
                        rankList: a.data.countList,
                        isMore: !1
                    });
                } else t.tips(i.data.msg);
            }
        });
    },
    loadMore: function() {
        var t = this.data.rankList.length, a = this.data.countList, i = a.length;
        if (i > t + 10) {
            var s = a.slice(t, t + 10);
            this.setData({
                rankList: this.data.rankList.concat(s),
                isMore: !0
            });
        } else {
            var e = a.slice(t, i);
            this.setData({
                rankList: this.data.rankList.concat(e),
                isMore: !1
            });
        }
    },
    getPoster: function() {
        var a = this, i = t.getNetAddresss("plugin.deposit-ladder.frontend.index.poster");
        wx.showLoading({
            title: "加载中"
        }), t._getNetWork({
            url: i,
            data: {
                id: this.data.activity_id
            },
            success: function(t) {
                wx.hideLoading();
                var i = t.data;
                1 == i.result ? a.setData({
                    posterImg: i.data.poster
                }) : wx.showToast({
                    title: i.msg
                });
            },
            fail: function() {
                wx.hideLoading();
            }
        });
    },
    hexStringToRGB: function(t) {
        t || (t = "#fec400");
        var a = t.toLowerCase();
        if (/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(a)) {
            if (4 === a.length) {
                for (var i = "#", s = 1; s < 4; s += 1) i += a.slice(s, s + 1).concat(a.slice(s, s + 1));
                a = i;
            }
            for (var e = [], r = 1; r < 7; r += 2) e.push(parseInt("0x" + a.slice(r, r + 2)));
            return e;
        }
        return [];
    },
    showSharePopup: function() {
        this.setData({
            isShow: !0
        }), this.data.posterImg || this.getPoster();
    },
    closeSharePopup: function() {
        this.setData({
            isShow: !1
        });
    },
    onShareAppMessage: function(t) {
        return this.data.shareOptions.share_title && this.data.shareOptions.share_img ? {
            path: "/packageH/deposit_group/rankList/rankList?id=".concat(this.data.activity_id),
            title: this.data.shareOptions.share_title,
            imgUrl: this.data.shareOptions.share_img
        } : {
            path: "/packageH/deposit_group/rankList/rankList?id=".concat(this.data.activity_id),
            title: "芸众商城",
            imgUrl: this.data.actData.goods_option.thumb
        };
    },
    onShareTimeline: function() {
        return this.data.shareOptions.share_title && this.data.shareOptions.share_img ? {
            query: "id=".concat(this.data.activity_id),
            title: this.data.shareOptions.share_title,
            imageUrl: this.data.shareOptions.share_img
        } : {
            path: "id=".concat(this.data.activity_id),
            title: "芸众商城"
        };
    }
});